<h1>Usuário</h1>

<div class="actions">
  <%= link_to "Editar", edit_user_path(@user) %>
</div>

<ul>
  <li>Name: <%= @user.name %></li>
  <li>Email: <%= @user.email %></li>
  <li>Username: <%= @user.username %></li>
  <li>Active: <%= @user.active %></li>
</ul>

<div id="user_groups">
  <h3>Grupos</h3>

  <ul>
    <% @user.group_users.each do |group_user| %>
      <li><%= group_user.group.name %> <%= link_to "Vincular perfis do grupo", user_permission_path(@user, group_user) %>
        <% group_user.role_group_users.each do |role_group_user|%>
          <p><%= role_group_user.role.name %></p>
        <% end %>
      </li>
    <% end %>
  </ul>
</div>

<div>
  <h3>Perfis</h3>

  <ul>
    <% @user.role_group_users.each do |permission| %>
      <li><%= permission.role.name %></li>
     <% end -%>
  </ul>
</div>

<%= link_to "Voltar", users_path %>
